import cProfile
import pstats
import os

def performance_info(function_name):
    if not os.path.exists(f"program_benchmark/{function_name}/"):
        os.makedirs(f"program_benchmark/{function_name}/")
    
    cProfile.run(f"{ function_name }()", f"program_benchmark/{function_name}/output.dat")

    with open(f"program_benchmark/{function_name}/output_time.txt", "w") as file:
        p = pstats.Stats(f"program_benchmark/{function_name}/output.dat", stream = file)
        p.sort_stats("time").print_stats()
    
    with open(f"program_benchmark/{function_name}/output_calls.txt", "w") as file:
        p = pstats.Stats(f"program_benchmark/{function_name}/output.dat", stream = file)
        p.sort_stats("calls").print_stats()